package LeetCode.leetcode;

import java.util.HashSet;
import java.util.Set;

/**
 * 存在重复元素
 * @author: leiwenkang02@meituan.com
 * @date: 2018/8/27
 * @time: 13:18
 */
public class Test217存在重复元素 {
    public boolean containsDuplicate(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])) {
                return true;
            }
            set.add(nums[i]);
        }
        return false;
    }
}
